<%@ page language="java" trimDirectiveWhitespaces="true" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	String appPath = request.getContextPath();
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0 , maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="${staticPath}/weui/lib/weui.min.css">
<link rel="stylesheet" href="${staticPath}/weui/css/jquery-weui.css">
<link rel="stylesheet" href="${staticPath}/css/style.css">
<script type="text/javascript" src="${staticPath}/js/jquery-2.1.4.js"></script>
<script type="text/javascript" src="${staticPath}/js/jquery.cookie.js"></script>
<script type="text/javascript" src="${staticPath}/js/jquery.md5.js"></script>
<script type="text/javascript" src="${staticPath}/js/validate.js"></script>
<script type="text/javascript" src="${staticPath}/weui/js/jquery-weui.js"></script>
<script type="text/javascript">var appPath="<%=appPath%>";</script>
<script type="text/javascript">var staticPath="${staticPath}";</script>
<script type="text/javascript">
	function gotoHtml(url){
		var tmp="?";
		if (url.indexOf("?")>=0){
			tmp="&";
		}
		
		var token=$.cookie("token");
		if (typeof(token) == "undefined") { 
			window.location.href=appPath+url;
		}else{
			window.location.href=appPath+url+tmp+"token="+token;
		}
				
	}
	function reloadHtml(){
		$.showLoading();
		window.location.reload();
	}
	function gotoHtmlTarget(url,target) {
		var tmp = "?";
		if (url.indexOf("?") >= 0) {
			tmp = "&";
		}
		if("1"==target){
			window.open(appPath + url + tmp + "token="+ $.cookie("token"));			
		}else{
			window.location.href = appPath + url + tmp + "token="
					+ $.cookie("token");
		}
	}
	
	
	function qqkefu(){
		if (/(applewebkitapp)/i.test(navigator.userAgent)) {
			window.location = 'js-call:weixin_ios_kefu:';
		} else if (/(androidapp)/i.test(navigator.userAgent)) {
			window.Weixin.kefu();
		} else {
			window.open("http://wpa.qq.com/msgrd?v=3&uin=3444827400&site=qq&menu=yes");	
		}
		
	}
	

	function reloadVerifyCode(id) {
		var timenow = new Date().getTime();
		$("#" + id).attr("src", appPath + "/member/getImageCode.htm?" + timenow);
	}
   function kefu() {
		$.actions({
			title : "选择客服方式",
			onClose : function() {
				//console.log("close");
			},
			actions : [/* {
				text : "QQ客服",
				className : "color-primary",
				onClick : function() {
					//$.alert("qq客服");
					qqkefu();
				}
			}, */{
				text : "400电话客服",
				className : "color-success",
				onClick : function() {
						window.location.href = "tel:4001391011";  
				}
			} , {
				text : "智能客服",
				className : "color-warning",
				onClick : function() {
					
					if (/(applewebkitapp)/i.test(navigator.userAgent)) {
						window.location = 'js-call:weixin_ios_znkefu:';
					} else if (/(androidapp)/i.test(navigator.userAgent)) {
						window.Weixin.znkefu();
					} else {
						window.location.href = "http://www.sobot.com/chat/h5/index.html?sysNum=86544a8a10e0487e92d92c2d42a89d14";
					}
					
				}
			} , {
				text : "取消",
				className : "weui_actionsheet_cancel",
				onClick : function() {
					//$.alert("你选择了“电话客服”");
		
				}
			} ]
		});
	}
   /**
    * 显示购物项数量
    */
   function getCartCount(){
   	//cartId-skuId-num-isBuy-isDel
   	var cartItemsStr = $.cookie("cartItems");
   	var cartCount = "0";
   	if(cartItemsStr){
   		var keyStr = "\\d*-\\d+-\\d+-\\d{1}-\\d{1}";
   		var rex = new RegExp(keyStr,"g");
   		var matches = cartItemsStr.match(rex);
   		if(matches!=null&&matches.length>0){
   			for(var i = 0;i<matches.length;i++){
   				if(matches[i].split("-")[4]!="1"){//非删除
   					cartCount = parseInt(cartCount)+ parseInt(matches[i].split("-")[2]);
   				}
   			}
   		}
   	}
   	return cartCount;
   }
   $(document).ready(function(){
	   if($(".cart").length==1){
		   var htmlDom ='<em class="cart_count" id="cart_count">'+getCartCount()+'</em>';
		   $(".cart").prepend(htmlDom);
	   }
   });
</script>
